//
// YDInOptionsCell.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/3/2.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDInOptionsCell.h"
#import "YDInOptionsModel.h"
#import "SYTextLeftButton.h"

@interface YDInOptionsCell()

//股票名称
@property (nonatomic , weak) UILabel *stockName;
//股票代码
@property (nonatomic , weak) UILabel *stockCode;
//当前状态
@property (nonatomic , weak) UIImageView *currentStatus;
//时间图示
@property (nonatomic , weak) UIImageView *timeImage;
//年月日
@property (nonatomic , weak) UILabel *year;
//时分秒
@property (nonatomic , weak) UILabel *hour;
//订单号
@property (nonatomic , weak) UILabel *orderLabel;
//订单number
@property (nonatomic , weak) UILabel *orderNumber;

//权利金
@property (nonatomic , weak) UILabel *rights;
//权利金数值
@property (nonatomic , weak) UILabel *rightsNumber;
//浮动盈亏
@property (nonatomic , weak) UILabel *floating;
//浮动盈亏数值
@property (nonatomic , weak) UILabel *floatingNumber;

//
@property (nonatomic , weak) UIView *hiddenView;


//名义本金
@property (nonatomic , weak) UILabel *principal;
//名义本金数值
@property (nonatomic , weak) UILabel *principalNumber;
//行权周期
@property (nonatomic , weak) UILabel *rightPrice;
//行权周期数值
@property (nonatomic , weak) UILabel *rightPriceNumber;

//成交价
@property (nonatomic , weak) UILabel *transactionPrice;
//成交价数值
@property (nonatomic , weak) UILabel *transactionPriceNumber;
//成交时间
@property (nonatomic , weak) UILabel *transactionTime;
//成交时间数值
@property (nonatomic , weak) UILabel *transactionTimeNumber;
//当前价
@property (nonatomic , weak) UILabel *nowPrice;
//当前价数值
@property (nonatomic , weak) UILabel *nowPriceNumber;
//到期时间
@property (nonatomic , weak) UILabel *experitTime;
//到期时间数值
@property (nonatomic , weak) UILabel *experitTimeNumber;

//卖出按钮
@property (nonatomic , weak) SYNoHeightedButton *saleButton;

@property (nonatomic , weak) SYTextLeftButton *openCloseButton;



@end

@implementation YDInOptionsCell


-(void)setModel:(YDInOptionsModel *)model
{
    _model = model;
    //股票名称代码 交易单号
    self.stockName.text = model.stockName;
    self.stockCode.text = model.stockCode;
    self.orderNumber.text = model.tradeNo;
    
    //时间
    self.year.text = model.pzYear;
    self.hour.text = model.pzHour;
    
    
    //权利金
    self.rightsNumber.text = model.pzRightMoney;
    
    
    //浮动盈亏
    if (!model.profit.length) {
        self.floatingNumber.text = @"---";
        self.floatingNumber.textColor = [UIColor colorWithHexString:dark];
    }else{
        if ([model.profit floatValue] > 0) {
            self.floatingNumber.textColor = [UIColor colorWithHexString:paleRed];
        }else if ([model.profit floatValue] < 0){
            self.floatingNumber.textColor = [UIColor colorWithHexString:leafyGreen];
        }else{
            self.floatingNumber.textColor = [UIColor colorWithHexString:dark];
        }
        self.floatingNumber.text = [NSString stringWithFormat:@"%@元" , model.pzProfit];
    }
    
    //成交价
    self.transactionPriceNumber.text = model.pzBuyPrice;
    self.transactionTimeNumber.textColor = [UIColor colorWithHexString:paleRed];
    //成交时间
    self.transactionTimeNumber.text = model.chengJiaoTime;
    //名义本金
    self.principalNumber.text = model.pzNominalAmount;
    //行权周期
    self.rightPriceNumber.text = model.cycleName;
    //当前价
    self.nowPriceNumber.text = model.pzLastPrice;
    self.nowPriceNumber.textColor = [UIColor colorWithHexString:paleRed];
    //到期时间
    self.experitTimeNumber.text = model.pzExpireTime;

    
    //状态
    /*
     WAITCONFIRMED("1", "待确认"),
     
     FAILURE("2", "申购失败"),
     
     TURNOVER("3", "持仓中"),
     
     APPLYRIGHT("4", "申请行权"),
     
     INSETTLEMENT("5", "结算中"),
     
     SETTLEMENTED("6", "已结算"),
     
     AUTOEXPIRE("7", "自动到期");
     */
    if ([model.state isEqualToString:@"WAITCONFIRMED"]) {
        self.currentStatus.image = [UIImage imageNamed:@"qq-daiqueren"];
    }else if ([model.state isEqualToString:@"FAILURE"]){
        self.currentStatus.image = [UIImage imageNamed:@"qq-shengoushibai"];
    }else if ([model.state isEqualToString:@"TURNOVER"]){
        self.currentStatus.image = [UIImage imageNamed:@"cc-chicangzhong"];
    }else if ([model.state isEqualToString:@"APPLYRIGHT"]){
        self.currentStatus.image = [UIImage imageNamed:@"qq-shenqingxingquan"];
    }else if ([model.state isEqualToString:@"INSETTLEMENT"]){
        self.currentStatus.image = [UIImage imageNamed:@"qq-jiesuanzhong"];
    }else if ([model.state isEqualToString:@"SETTLEMENTED"]){
        self.currentStatus.image = [UIImage imageNamed:@"qq-yijiesuan"];
    }else if ([model.state isEqualToString:@"AUTOEXPIRE"]){
        self.currentStatus.image = [UIImage imageNamed:@"qq-zidongdaoqi"];
    }
    
    
    
    //卖出按钮状态
    self.saleButton.enabled = model.isCanSale;
    
    self.openCloseButton.selected = model.isSelected;
    
    self.hiddenView.hidden = !model.isSelected;
    
    
    
    //是不是停牌了
    if ([model.stockStatus integerValue] == 1) {//正常
        self.nowPriceNumber.textColor = [UIColor colorWithHexString:paleRed];
    }else{//停牌
        self.nowPriceNumber.text = @"停牌";
        self.nowPriceNumber.textColor = [UIColor colorWithHexString:dark];
    }
    
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *inOptionsCell = @"YDInOptionsCell";
    YDInOptionsCell *cell = [tableView dequeueReusableCellWithIdentifier:inOptionsCell];
    if (cell == nil) {
        cell = [[YDInOptionsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:inOptionsCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backgroundColor = [UIColor whiteColor];
        
        [self addDashLine];
        
        [self stockName];//股票名称
        [self stockCode];//股票代码
        [self currentStatus];//当前状态
        [self timeImage];//时间图示
        [self year];//年月日
        [self hour];//时分秒
        
        
        //订单号
        [self orderLabel];
        [self orderNumber];
        
        
        
        [self rights];//权利金
        [self rightsNumber];//权利金数值
        [self floating];//浮动盈亏
        [self floatingNumber];//浮动盈亏数值
    
        [self principal];//名义本金
        [self principalNumber];//名义本金数值
        [self rightPrice];//行权周期
        [self rightPriceNumber];//行权周期数值

        
        
        
        [self hiddenView];
        
        
        [self transactionPrice];//成交价
        [self transactionPriceNumber];//成交价数值
        [self transactionTime];//成交时间
        [self transactionTimeNumber];//成交时间数值
        [self nowPrice];//当前价
        [self nowPriceNumber];//当前价数值
        [self experitTime];//到期时间
        [self experitTimeNumber];//到期时间数值
        
        [self saleButton];//卖出按钮
        [self openCloseButton];

    }
    return self;
}

/****股票名称*****/
-(UILabel *)stockName
{
    if (_stockName == nil) {
        UILabel *stockName = [[UILabel alloc] init];
        [self.contentView addSubview:stockName];
        stockName.textColor = [UIColor colorWithHexString:dark];
        stockName.font = [UIFont systemFontOfSize:font18ScreenWRate * LKScreenW];
        stockName.textAlignment = NSTextAlignmentLeft;
        stockName.text = @"平安银行";
        [stockName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(15));
            if (isPhoneX) {
                make.top.equalTo(self).offset(rateX812(15));
            }else{
                make.top.equalTo(self).offset(rate750(15));
            }
            
        }];
        _stockName = stockName;
    }
    return _stockName;
}
/****股票代码*****/
-(UILabel *)stockCode
{
    if (_stockCode == nil) {
        UILabel *stockCode = [[UILabel alloc] init];
        [self.contentView addSubview:stockCode];
        stockCode.textColor = [UIColor colorWithHexString:blueyGrey];
        stockCode.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        stockCode.textAlignment = NSTextAlignmentLeft;
        stockCode.text = @"000001";
        [stockCode mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockName.mas_right).offset(rate375(4));
            make.centerY.equalTo(self.stockName);
        }];
        _stockCode = stockCode;
    }
    return _stockCode;
}
/****当前状态*****/
-(UIImageView *)currentStatus
{
    if (_currentStatus == nil) {
        UIImageView *currentStatus = [[UIImageView alloc] init];
        [self.contentView addSubview:currentStatus];
        [currentStatus setBackgroundColor:[UIColor clearColor]];
        [currentStatus mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockCode.mas_right).offset(rate375(5));
            make.centerY.equalTo(self.stockName);
        }];
        _currentStatus = currentStatus;
    }
    return _currentStatus;
}
/****时间图示*****/
-(UIImageView *)timeImage
{
    if (_timeImage == nil) {
        UIImageView *timeImage = [[UIImageView alloc] init];
        [self.contentView addSubview:timeImage];
        timeImage.image = [UIImage imageNamed:@"cc-time"];
        timeImage.backgroundColor = [UIColor clearColor];
        timeImage.contentMode = UIViewContentModeScaleAspectFill;
        [timeImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.equalTo(@(rate375(10)));
            make.left.equalTo(self.stockName);
            if (isPhoneX) {
                make.top.equalTo(self.stockName.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.stockName.mas_bottom).offset(rate750(6));
            }
        }];
        _timeImage = timeImage;
    }
    return _timeImage;
}
/****年月日*****/
-(UILabel *)year
{
    if (_year == nil) {
        UILabel *year = [[UILabel alloc] init];
        [self.contentView addSubview:year];
        year.textColor = [UIColor colorWithHexString:blueyGrey];
        year.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        year.textAlignment = NSTextAlignmentLeft;
        year.text = @"2017.11.09";
        [year mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.timeImage.mas_right).offset(rate375(5));
            make.centerY.equalTo(self.timeImage);
        }];
        _year = year;
    }
    return _year;
}
/****时分秒*****/
-(UILabel *)hour
{
    if (_hour == nil) {
        UILabel *hour = [[UILabel alloc] init];
        [self.contentView addSubview:hour];
        hour.textColor = [UIColor colorWithHexString:blueyGrey];
        hour.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        hour.textAlignment = NSTextAlignmentLeft;
        hour.text = @"11:02:09";
        [hour mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.year.mas_right).offset(rate375(10));
            make.centerY.equalTo(self.timeImage);
        }];
        _hour = hour;
    }
    return _hour;
}
/****订单*****/
-(UILabel *)orderLabel
{
    if (_orderLabel == nil) {
        UILabel *orderLabel = [[UILabel alloc] init];
        [self.contentView addSubview:orderLabel];
        orderLabel.textColor = [UIColor colorWithHexString:blueyGrey];
        orderLabel.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        orderLabel.textAlignment = NSTextAlignmentLeft;
        orderLabel.text = @"交易订单";
        [orderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockName);
            if (isPhoneX) {
                make.top.equalTo(self.timeImage.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.timeImage.mas_bottom).offset(rate750(6));
            }
        }];
        _orderLabel = orderLabel;
    }
    return _orderLabel;
}

/****订单号*****/
-(UILabel *)orderNumber
{
    if (_orderNumber == nil) {
        UILabel *orderNumber = [[UILabel alloc] init];
        [self.contentView addSubview:orderNumber];
        orderNumber.textColor = [UIColor colorWithHexString:blueyGrey];
        orderNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        orderNumber.textAlignment = NSTextAlignmentLeft;
        orderNumber.text = @"12345678912";
        [orderNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.orderLabel.mas_right).offset(rate375(7));
            make.centerY.equalTo(self.orderLabel);
        }];
        orderNumber.adjustsFontSizeToFitWidth = YES;
        _orderNumber = orderNumber;
    }
    return _orderNumber;
}


//////////////////////////////////////////////////////////////////
//权利金
-(UILabel *)rights
{
    if (_rights == nil) {
        UILabel *rights = [[UILabel alloc] init];
        [self.contentView addSubview:rights];
        rights.textColor = [UIColor colorWithHexString:blueyGrey];
        rights.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        rights.textAlignment = NSTextAlignmentLeft;
        rights.text = @"权利金";
        [rights mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stockName.mas_left);
            if (isPhoneX) {
                make.top.equalTo(self).offset(rateX812(100));
            }else{
                make.top.equalTo(self).offset(rate750(100));
            }
            make.width.equalTo(@(rate375(50)));
        }];
        rights.adjustsFontSizeToFitWidth = YES;
        _rights = rights;
    }
    return _rights;
}
//权利金数值
-(UILabel *)rightsNumber
{
    if (_rightsNumber == nil) {
        UILabel *rightsNumber = [[UILabel alloc] init];
        [self.contentView addSubview:rightsNumber];
        rightsNumber.textColor = [UIColor colorWithHexString:dark];
        rightsNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        rightsNumber.textAlignment = NSTextAlignmentLeft;
        rightsNumber.text = @"16542元";
        [rightsNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.rights.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.rights);
            make.right.equalTo(self.mas_centerX).offset(rate375(40));
        }];
        rightsNumber.adjustsFontSizeToFitWidth = YES;
        rightsNumber.adjustsFontSizeToFitWidth = YES;
        _rightsNumber = rightsNumber;
    }
    return _rightsNumber;
}

//浮动盈亏
-(UILabel *)floating
{
    if (_floating == nil) {
        UILabel *floating = [[UILabel alloc] init];
        [self.contentView addSubview:floating];
        floating.textColor = [UIColor colorWithHexString:blueyGrey];
        floating.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        floating.textAlignment = NSTextAlignmentLeft;
        floating.text = @"浮动盈亏";
        [floating mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.rights.mas_left);
            if (isPhoneX) {
                make.top.equalTo(self.rights.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.rights.mas_bottom).offset(rate750(6));
            }
            make.width.equalTo(@(rate375(50)));
        }];
        floating.adjustsFontSizeToFitWidth = YES;
        _floating = floating;
    }
    return _floating;
}
//浮动盈亏数值
-(UILabel *)floatingNumber
{
    if (_floatingNumber == nil) {
        UILabel *floatingNumber = [[UILabel alloc] init];
        [self.contentView addSubview:floatingNumber];
        floatingNumber.textColor = [UIColor colorWithHexString:dark];
        floatingNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        floatingNumber.textAlignment = NSTextAlignmentLeft;
        floatingNumber.text = @"18979元";
        [floatingNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.floating.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.floating);
            make.right.equalTo(self.mas_centerX).offset(rate375(40));
        }];
        floatingNumber.adjustsFontSizeToFitWidth = YES;
        _floatingNumber = floatingNumber;
    }
    return _floatingNumber;
}

//名义本金
-(UILabel *)principal
{
    if (_principal == nil) {
        UILabel *principal = [[UILabel alloc] init];
        [self.contentView addSubview:principal];
        principal.textColor = [UIColor colorWithHexString:blueyGrey];
        principal.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        principal.textAlignment = NSTextAlignmentLeft;
        principal.text = @"名义本金";
        [principal mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(rate375(235));
            make.centerY.equalTo(self.rights);
            make.width.equalTo(@(rate375(50)));
        }];
        principal.adjustsFontSizeToFitWidth = YES;
        _principal = principal;
    }
    return _principal;
}

//名义本金数值
-(UILabel *)principalNumber
{
    if (_principalNumber == nil) {
        UILabel *principalNumber = [[UILabel alloc] init];
        [self.contentView addSubview:principalNumber];
        principalNumber.textColor = [UIColor colorWithHexString:dark];
        principalNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        principalNumber.textAlignment = NSTextAlignmentLeft;
        principalNumber.text = @"1万元";
        [principalNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.principal.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.principal);
            make.right.equalTo(self).offset(-rate375(15));
        }];
        principalNumber.adjustsFontSizeToFitWidth = YES;
        _principalNumber = principalNumber;
    }
    return _principalNumber;
}
//行权周期
-(UILabel *)rightPrice
{
    if (_rightPrice == nil) {
        UILabel *rightPrice = [[UILabel alloc] init];
        [self.contentView addSubview:rightPrice];
        rightPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        rightPrice.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        rightPrice.textAlignment = NSTextAlignmentLeft;
        rightPrice.text = @"行权周期";
        [rightPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.principal.mas_left);
            if (isPhoneX) {
                make.top.equalTo(self.principal.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.principal.mas_bottom).offset(rate750(6));
            }
            make.width.equalTo(@(rate375(50)));
        }];
        rightPrice.adjustsFontSizeToFitWidth = YES;
        _rightPrice = rightPrice;
    }
    return _rightPrice;
}
//行权周期数值
-(UILabel *)rightPriceNumber
{
    if (_rightPriceNumber == nil) {
        UILabel *rightPriceNumber = [[UILabel alloc] init];
        [self.contentView addSubview:rightPriceNumber];
        rightPriceNumber.textColor = [UIColor colorWithHexString:dark];
        rightPriceNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        rightPriceNumber.textAlignment = NSTextAlignmentLeft;
        rightPriceNumber.text = @"一个月";
        [rightPriceNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.rightPrice.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.rightPrice);
            make.right.equalTo(self).offset(-rate375(15));
            
        }];
        rightPriceNumber.adjustsFontSizeToFitWidth = YES;
        _rightPriceNumber = rightPriceNumber;
    }
    return _rightPriceNumber;
}


-(UIView *)hiddenView
{
    if (_hiddenView == nil) {
        UIView *hiddenView = [[UIView alloc] init];
        [self.contentView addSubview:hiddenView];
        hiddenView.backgroundColor = [UIColor clearColor];
        [hiddenView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self);
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(40)));
                make.top.equalTo(self.rightPrice.mas_bottom).offset(rateX812(6));
            }else{
                make.height.equalTo(@(rate750(40)));
                make.top.equalTo(self.rightPrice.mas_bottom).offset(rate750(6));
            }
        }];
        _hiddenView = hiddenView;
    }
    return _hiddenView;
}


//成交价
-(UILabel *)transactionPrice
{
    if (_transactionPrice == nil) {
        UILabel *transactionPrice = [[UILabel alloc] init];
        [self.hiddenView addSubview:transactionPrice];
        transactionPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        transactionPrice.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        transactionPrice.textAlignment = NSTextAlignmentLeft;
        transactionPrice.text = @"成交价";
        [transactionPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.rights.mas_left);
            make.top.equalTo(self.hiddenView);
            make.width.equalTo(@(rate375(50)));
        }];
        transactionPrice.adjustsFontSizeToFitWidth = YES;
        _transactionPrice = transactionPrice;
    }
    return _transactionPrice;
}
//成交价数值
-(UILabel *)transactionPriceNumber
{
    if (_transactionPriceNumber == nil) {
        UILabel *transactionPriceNumber = [[UILabel alloc] init];
        [self.hiddenView addSubview:transactionPriceNumber];
        transactionPriceNumber.textColor = [UIColor colorWithHexString:dark];
        transactionPriceNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        transactionPriceNumber.textAlignment = NSTextAlignmentLeft;
        transactionPriceNumber.text = @"30.01";
        [transactionPriceNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.transactionPrice.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.transactionPrice);
        }];
        transactionPriceNumber.adjustsFontSizeToFitWidth = YES;
        _transactionPriceNumber = transactionPriceNumber;
    }
    return _transactionPriceNumber;
}
//成交时间
-(UILabel *)transactionTime
{
    if (_transactionTime == nil) {
        UILabel *transactionTime = [[UILabel alloc] init];
        [self.hiddenView addSubview:transactionTime];
        transactionTime.textColor = [UIColor colorWithHexString:blueyGrey];
        transactionTime.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        transactionTime.textAlignment = NSTextAlignmentLeft;
        transactionTime.text = @"成交时间";
        [transactionTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.transactionPrice.mas_left);
            if (isPhoneX) {
                make.top.equalTo(self.transactionPrice.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.transactionPrice.mas_bottom).offset(6);
            }
            make.width.equalTo(@(rate375(50)));
        }];
        transactionTime.adjustsFontSizeToFitWidth = YES;
        _transactionTime = transactionTime;
    }
    return _transactionTime;
}
//成交时间数值
-(UILabel *)transactionTimeNumber
{
    if (_transactionTimeNumber == nil) {
        UILabel *transactionTimeNumber = [[UILabel alloc] init];
        [self.hiddenView addSubview:transactionTimeNumber];
        transactionTimeNumber.textColor = [UIColor colorWithHexString:dark];
        transactionTimeNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        transactionTimeNumber.textAlignment = NSTextAlignmentLeft;
        transactionTimeNumber.text = @"2019-03-09";
        [transactionTimeNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.transactionTime.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.transactionTime);
        }];
        transactionTimeNumber.adjustsFontSizeToFitWidth = YES;
        _transactionTimeNumber = transactionTimeNumber;
    }
    return _transactionTimeNumber;
}

//当前价
-(UILabel *)nowPrice
{
    if (_nowPrice == nil) {
        UILabel *nowPrice = [[UILabel alloc] init];
        [self.hiddenView addSubview:nowPrice];
        nowPrice.textColor = [UIColor colorWithHexString:blueyGrey];
        nowPrice.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        nowPrice.textAlignment = NSTextAlignmentLeft;
        nowPrice.text = @"当前价";
        [nowPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(rate375(235));
            make.centerY.equalTo(self.transactionPrice);
            make.width.equalTo(@(rate375(50)));
        }];
        nowPrice.adjustsFontSizeToFitWidth = YES;
        _nowPrice = nowPrice;
    }
    return _nowPrice;
}
//当前价数值
-(UILabel *)nowPriceNumber
{
    if (_nowPriceNumber == nil) {
        UILabel *nowPriceNumber = [[UILabel alloc] init];
        [self.hiddenView addSubview:nowPriceNumber];
        nowPriceNumber.textColor = [UIColor colorWithHexString:dark];
        nowPriceNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        nowPriceNumber.textAlignment = NSTextAlignmentLeft;
        nowPriceNumber.text = @"30.08";
        [nowPriceNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nowPrice.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.nowPrice);
            make.right.equalTo(self).offset(-rate375(15));
        }];
        nowPriceNumber.adjustsFontSizeToFitWidth = YES;
        _nowPriceNumber = nowPriceNumber;
    }
    return _nowPriceNumber;
}
//到期时间
-(UILabel *)experitTime
{
    if (_experitTime == nil) {
        UILabel *experitTime = [[UILabel alloc] init];
        [self.hiddenView addSubview:experitTime];
        experitTime.textColor = [UIColor colorWithHexString:blueyGrey];
        experitTime.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        experitTime.textAlignment = NSTextAlignmentLeft;
        experitTime.text = @"到期时间";
        [experitTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.nowPrice.mas_left);
            if (isPhoneX) {
                make.top.equalTo(self.nowPrice.mas_bottom).offset(rateX812(6));
            }else{
                make.top.equalTo(self.nowPrice.mas_bottom).offset(6);
            }
            make.width.equalTo(@(rate375(50)));
        }];
        experitTime.adjustsFontSizeToFitWidth = YES;
        _experitTime = experitTime;
    }
    return _experitTime;
}
//到期时间数值
-(UILabel *)experitTimeNumber
{
    if (_experitTimeNumber == nil) {
        UILabel *experitTimeNumber = [[UILabel alloc] init];
        [self.hiddenView addSubview:experitTimeNumber];
        experitTimeNumber.textColor = [UIColor colorWithHexString:dark];
        experitTimeNumber.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        experitTimeNumber.textAlignment = NSTextAlignmentLeft;
        experitTimeNumber.text = @"2018-04-24";
        [experitTimeNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.experitTime.mas_right).offset(rate375(6));
            make.centerY.equalTo(self.experitTime);
            make.right.equalTo(self).offset(-rate375(15));
        }];
        experitTimeNumber.adjustsFontSizeToFitWidth = YES;
        _experitTimeNumber = experitTimeNumber;
    }
    return _experitTimeNumber;
}




/****卖出按钮*****/
-(SYNoHeightedButton *)saleButton
{
    if (_saleButton == nil) {
        SYNoHeightedButton *saleButton = [SYNoHeightedButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:saleButton];
        [saleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [saleButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
        [saleButton setTitle:@"卖出" forState:UIControlStateNormal];
        [saleButton setTitle:@"卖出" forState:UIControlStateDisabled];
        [saleButton setBackgroundImage:[UIImage imageWithColor:zhidainMainColor] forState:UIControlStateNormal];
        [saleButton setBackgroundImage:[UIImage imageWithColor:zhidianAlprColor(0.3)] forState:UIControlStateDisabled];
        saleButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        saleButton.titleLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        [saleButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.equalTo(@(rate375(125)));
            make.right.equalTo(self).offset(-rate375(15));
            if (isPhoneX) {
                make.height.equalTo(@(rateX812(30)));
                make.top.equalTo(self).offset(rateX812(15));
            }else{
                make.height.equalTo(@(rate750(30)));
                make.top.equalTo(self).offset(rate750(15));
            }
            
        }];
        
        saleButton.layer.cornerRadius = 3.0;
        saleButton.layer.masksToBounds = YES;
        
        [saleButton addTarget:self action:@selector(saleButtonClick) forControlEvents:UIControlEventTouchDown];
        
        _saleButton = saleButton;
    }
    return _saleButton;
}
//卖出按钮
-(void)saleButtonClick
{
//    DDLog(@"点击卖出按钮")
    if (self.delegate && [self.delegate respondsToSelector:@selector(inOptionsCellDidClickSaleButton:)]) {
        [self.delegate inOptionsCellDidClickSaleButton:self];
        
    }
}
-(SYTextLeftButton *)openCloseButton
{
    if (_openCloseButton == nil) {
        SYTextLeftButton *openCloseButton = [SYTextLeftButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:openCloseButton];
        openCloseButton.backgroundColor = [UIColor whiteColor];
        [openCloseButton setTitleColor:[UIColor colorWithHexString:frenchBlue] forState:UIControlStateNormal];
        [openCloseButton setTitleColor:[UIColor colorWithHexString:frenchBlue] forState:UIControlStateSelected];
        
        [openCloseButton setTitle:@"展开" forState:UIControlStateNormal];
        [openCloseButton setTitle:@"收起" forState:UIControlStateSelected];
        
        
        [openCloseButton setImage:[UIImage imageNamed:@"optionsjiantouNor"] forState:UIControlStateNormal];
        [openCloseButton setImage:[UIImage imageNamed:@"optionsjiantouSel"] forState:UIControlStateSelected];
        
        openCloseButton.titleLabel.textAlignment = NSTextAlignmentCenter;
        openCloseButton.titleLabel.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        [openCloseButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.saleButton.mas_right).offset(-10);
            if (isPhoneX) {
                make.top.equalTo(self.saleButton.mas_bottom).offset(rateX812(15));
            }else{
                make.top.equalTo(self.saleButton.mas_bottom).offset(rate750(15));
            }
            
        }];
        
        [openCloseButton addTarget:self action:@selector(openCloseButtonClick) forControlEvents:UIControlEventTouchDown];
        
        _openCloseButton = openCloseButton;
    }
    return _openCloseButton;
}
-(void)openCloseButtonClick
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(inOptionsCellDidClickOpenButton:)]) {
        [self.delegate inOptionsCellDidClickOpenButton:self];
    }
}

-(void)addDashLine
{
    CGFloat y = isPhoneX ? rateX812(88) : rate750(88);
    CAShapeLayer *layer = [CAShapeLayer layer];
    layer.lineWidth = 1.0f;
    layer.strokeColor = [UIColor lightGrayColor].CGColor;
    [layer setLineDashPattern:[NSArray arrayWithObjects:[NSNumber numberWithInt:2],[NSNumber numberWithInt:2],nil]];
    UIBezierPath *path = [UIBezierPath bezierPath];
    [path moveToPoint:CGPointMake(rate375(10),y)];
    [path addLineToPoint:CGPointMake(LKScreenW - rate375(10),y)];
    layer.path = path.CGPath;
    [self.layer addSublayer:layer];
}



-(void)setFrame:(CGRect)frame
{
    CGFloat margin;
    if (isPhoneX) {
        margin = rateX812(5);
    }else{
        margin = rate750(5);
    }
    frame.size.height -= margin * 2;
    frame.origin.y += margin;
    [super setFrame:frame];
}

@end
